﻿package view.popup
{
    import com.sh.game.global.*;
    import flash.events.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import view.popup.ui.*;

    public class DBQBRankCtrl extends DBQBRankUI implements IDialogUI
    {
        private var rankValues:Array;

        public function DBQBRankCtrl()
        {
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            this.list.renderHandler = new Handler(this.renderHandler);
            closeBtn.addEventListener(MouseEvent.CLICK, this.onClose);
            rankrew.addEventListener(MouseEvent.CLICK, this.showRews);
            rankrew.visible = false;
            return;
        }// end function

        protected function showRews(event:MouseEvent) : void
        {
            return;
        }// end function

        protected function onClose(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        public function show(param1:Object) : void
        {
            var _loc_3:Object = null;
            this.rankValues = new Array();
            var _loc_2:int = 0;
            while (_loc_2 < param1.length)
            {
                
                _loc_3 = param1[_loc_2];
                _loc_3[5] = _loc_2 + 1;
                this.rankValues.push(_loc_3);
                _loc_2++;
            }
            this.list.array = this.rankValues;
            this.visible = true;
            x = (GlobalLayer.instance.root.stageWidth - width) / 2;
            y = (GlobalLayer.instance.root.stageHeight - height) / 2 - 100;
            return;
        }// end function

        private function renderHandler(param1:Box, param2:int) : void
        {
            var _loc_3:* = param1.getChildByName("ranktxt") as Label;
            var _loc_4:* = param1.getChildByName("nametxt") as Label;
            var _loc_5:* = param1.getChildByName("jftxt") as Label;
            var _loc_6:* = param1.getChildByName("killtxt") as Label;
            var _loc_7:* = this.rankValues[param2];
            if (this.rankValues[param2])
            {
                _loc_3.text = _loc_7[5];
                _loc_4.text = _loc_7[1];
                _loc_5.text = _loc_7[4];
                _loc_6.text = int(_loc_7[2]) + int(_loc_7[3]) + "";
            }
            else
            {
                _loc_3.text = "";
                _loc_4.text = "";
                _loc_5.text = "";
                _loc_6.text = "";
            }
            return;
        }// end function

        public function close() : void
        {
            visible = false;
            return;
        }// end function

    }
}
